package com.cardbaobao.cardbabyclient.ui.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.alibaba.android.vlayout.DelegateAdapter;
import com.alibaba.android.vlayout.LayoutHelper;
import com.alibaba.android.vlayout.layout.SingleLayoutHelper;
import com.cardbaobao.cardbabyclient.R;

/**
 * Created by Jiangzx on 2017/7/7 10:50.
 * 用于alibaba v-layout 列表无数据时
 */

public class NoDataDelegateAdapter extends DelegateAdapter.Adapter<RecyclerView.ViewHolder> {
    private SingleLayoutHelper layoutHelper;
    public NoDataDelegateAdapter(){
        this.layoutHelper=new SingleLayoutHelper();
    }
    @Override
    public LayoutHelper onCreateLayoutHelper() {
        return this.layoutHelper;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView= LayoutInflater.from(parent.getContext()).
                inflate(R.layout.item_no_data,parent,false);
        return new NoDataHolder(itemView);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

    }

    @Override
    public int getItemCount() {
        return 1;
    }

    private class NoDataHolder extends RecyclerView.ViewHolder{
        private NoDataHolder(View itemView){
            super(itemView);
            itemView.setVisibility(View.VISIBLE);
        }
    }
}
